Stored Procedures [dbo].[BAERosterManagementRecordDelete]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@UIDvarchar(10)10
@RemovalCodevarchar(60)60
@managerIDvarchar(10)10
SQL Script
/* LOGIC:
    This also has to be logged in the iMIS Name_Log table.

    This stored procedure is responsible for changing a user's status so that they are removed from the roster.
    This procedure may be edited to suit the needs of the organization.  This is to be used in junction with
    the results given in RosterManagementGetRemovalReasonCodes.  The reason codes have a removal_id and
    description with each record. This procedure is meant to be manually edited to handle each of these reasons
    separately.  For example, if an organization had two options for reasons for removal, they may want to completely
    remove the member from the roster entirely from one choice, and want to just change a member status type for the other choice.

    A simple case:  
        RosterManagementGetRemovalReasonCodes returns:
        ----------------------------------------------------
        | REMOVAL_ID | DESCRIPTION                         |
        ----------------------------------------------------
        | 1             | Retired                             |
        | 2          | Voluntarily Left                    |
        | 3          | Other                               |
        ----------------------------------------------------

    Could yield:
    
    IF (@RemovalCode = 1)
        BEGIN
            UPDATE imisDB..Name SET MEMBER_TYPE = 'RET', CO_ID = '' WHERE ID = @UID;
        END

    IF (@RemovalCode = 2)
        BEGIN
            UPDATE imisDB..Name SET MEMBER_TYPE = 'VOL', CO_ID = '' WHERE ID = @UID;
        END

    IF (@RemovalCode = 3)
        BEGIN
            UPDATE imisDB..Name SET WHERE ID = @UID;
        END

    Keep in mind that that the records returned are determined by the stored procedure that is
    represented by the RosterManagementAvailableRecordsStoredProc config variable.

    Parameters:
        @UID - User's ID to be updated.
        @RemovalCode - the removal code that the user is going to be changed to
        @managerID - the ID of the user that performs this action.  Will be a roster manager.
*/

CREATE PROCEDURE [dbo].[BAERosterManagementRecordDelete]
    @UID VARCHAR(10),
    @RemovalCode VARCHAR(60),
    @managerID VARCHAR(10)
AS
    DECLARE @removalReason varchar(128);
    DECLARE @removalDescription varchar(500);

    --GENERAL--
    /*Explanation of general:
        NOTE: This example is supposed to be here as an EXAMPLE ONLY.  While this code will
        work and work as intended, it is STRONGLY ADVISED to be edited to better suit your
        website.

        This function dictates that a person's member type stays the same when any removal code
        is given, except if the selection is 'deceased'.  If a member is deceased, the member type
        will be changed to 'D'.  

        Once again, this example is for demonstration purposes only.  It is inteded to work, but
        it is advised to be changed on a per-site basis.
    */

    DECLARE @currentMemberType varchar(5);

    SET @currentMemberType = (SELECT MEMBER_TYPE FROM Name WHERE ID = @UID);
    
    BEGIN
        UPDATE Name SET CO_ID = '' WHERE ID = @UID;
    END
    
    ---------------------    

    --LEAVE THESE THREE LINES IN.  THEY PUT THE DATA INTO THE NAME LOG
    SET @removalReason = (SELECT DESCRIPTION FROM Gen_Tables WHERE CODE = @RemovalCode AND TABLE_NAME = 'ROSTER_REMOVAL_REASON_CODE');
    
    SET @removalDescription = 'REMOVAL_DESCRIPTION: ' + @removalReason + ' (' + CAST(@RemovalCode as varchar(60)) + ')';
    
    INSERT INTO Name_Log (DATE_TIME, LOG_TYPE, SUB_TYPE, USER_ID, ID, LOG_TEXT) VALUES(GETDATE(), 'CHANGE', 'CHANGE', @managerID, @UID, @removalDescription);

GO
Uses